package com.scsj.supermarket.presenter;

import android.util.Log;

import com.orhanobut.logger.Logger;
import com.scsj.supermarket.base.CancelMineOrderBase;
import com.scsj.supermarket.base.GoodsDetailBase;
import com.scsj.supermarket.bean.CancelOrderBean;
import com.scsj.supermarket.bean.QueryGoodsDetailBean;
import com.scsj.supermarket.model.CancelMineOrderModel;
import com.scsj.supermarket.model.GoodsDetailModel;

import dkmvp.mvp.BasePresenter;
import dkmvp.net.ResponseCallback;
import okhttp3.RequestBody;

/**
 * Created by Administrator on 2018/6/26.
 */

public class GoodsDetailPresenter extends BasePresenter implements GoodsDetailBase.IPresenter {
    private GoodsDetailBase.IView mView;
    private GoodsDetailBase.IModel mModel;

    public GoodsDetailPresenter(GoodsDetailBase.IView mView) {
        this.mView = mView;
        mModel = new GoodsDetailModel();
    }

    @Override
    public void deliverData(RequestBody requestBody) {
        addSubscription(mModel.getData(requestBody, new ResponseCallback<QueryGoodsDetailBean>() {
            @Override
            public void onSuccess(QueryGoodsDetailBean result) {

                if (result.getStatusCode()== 200) {
                    mView.showSuccessMsg("获取成功",result);
                    Logger.e("获取成功" + result.toString());
                } else {
                    mView.showErrorMsg(result.getMsg());
                    Logger.e("未成功" + result.toString());
                }
            }

            @Override
            public void onFaild(String msg) {
                mView.showErrorMsg(msg);
                Log.e("失败", msg + "");
            }
        }));
    }
}
